package com.shinewind.task.timer;

import com.shinewind.common.util.RecommendUtils;
import com.shinewind.pojo.entity.Rating;
import com.shinewind.task.service.IRateService;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.List;

@Component
@Slf4j
public class RecommendModelTask {
    @Autowired
    private IRateService iRateService;

    @XxlJob("trainModel")
    public void trainModel() throws IOException {
         //将评分表中的信息封装成列表
        List<Rating> ratings = iRateService.getAllRates();
        //创建dataCsv文件
        RecommendUtils.createDataCsv(ratings);
        RecommendUtils.createTestCsv(10);
    }
}
